package com.ljx.recruitment.user.enums;

import com.ljx.recruitment.security.common.MenuConstant;
import com.ljx.recruitment.security.common.PermissionConstant;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @Author: LiJunXi
 * @Description:
 * @Date: 2024-10-16  21:35
 */
@Getter
@AllArgsConstructor
public enum CommonRoleEnum {

    PLATFORM("platform"),
    ADMIN("admin"),
    HR("hr"),
    USER("user"),
    STAFF("staff"),
    ANONYMOUS("anonymous");

    private String key;

    public static String getAdminCode(String code){
        return code + "_" + ADMIN.key;
    }

    public static String getUserCode(String code){
        return code + "_" + USER.key;
    }

    public static String getStaffCode(String code){
        return code + "_" + STAFF.key;
    }

    public static String getHrCode(String code){
        return code + "_" + HR.key;
    }

    public static String getAnonymousCode(String code){
        return code + "_" + ANONYMOUS.key;
    }

    public static List<String> initPermissionByRole(String roleName) {
        if (roleName.contains(ADMIN.key)) {
            return Arrays.asList(PermissionConstant.USER_QUERY, PermissionConstant.USER_SUBMIT, PermissionConstant.ROLE_SUBMIT,
                    PermissionConstant.ROLE_QUERY, PermissionConstant.TENANT_QUERY, PermissionConstant.TENANT_SUBMIT,
                    PermissionConstant.LOCATION_QUERY, PermissionConstant.LOCATION_SUBMIT, PermissionConstant.JOB_QUERY,
                    PermissionConstant.JOB_SUBMIT, PermissionConstant.RESUME_SUBMIT, PermissionConstant.RESUME_QUERY,
                    PermissionConstant.FILE_DOWNLOAD, PermissionConstant.FILE_UPLOAD, PermissionConstant.ADMIN_USER_QUERY,
                    PermissionConstant.ADMIN_USER_SUBMIT, PermissionConstant.ADMIN_TENANT_SUBMIT, PermissionConstant.ADMIN_OPTION_QUERY,
                    PermissionConstant.ADMIN_DELIVER_QUERY, PermissionConstant.ADMIN_DELIVER_SUBMIT);
        } else if(roleName.contains(HR.key)) {
            return Arrays.asList(PermissionConstant.USER_QUERY, PermissionConstant.USER_SUBMIT, PermissionConstant.FILE_DOWNLOAD,
                    PermissionConstant.FILE_UPLOAD,  PermissionConstant.ADMIN_OPTION_QUERY, PermissionConstant.ADMIN_DELIVER_QUERY,
                    PermissionConstant.ADMIN_DELIVER_SUBMIT);
        } else if(roleName.contains(USER.key)) {
            return Arrays.asList(PermissionConstant.USER_QUERY, PermissionConstant.USER_SUBMIT, PermissionConstant.USER_DELIVER,
                    PermissionConstant.FILE_DOWNLOAD, PermissionConstant.FILE_UPLOAD, PermissionConstant.RESUME_SUBMIT);
        } else if(roleName.contains(STAFF.key)) {
            return Arrays.asList(PermissionConstant.USER_QUERY, PermissionConstant.USER_SUBMIT, PermissionConstant.USER_DELIVER,
                    PermissionConstant.FILE_DOWNLOAD, PermissionConstant.FILE_UPLOAD);
        }
        return new ArrayList<>();
    }

    public static List<String> initMenuByRole(String roleName) {
        if (roleName.contains(ADMIN.key)) {
            return Arrays.asList(MenuConstant.DASHBOARD_ADMIN, MenuConstant.THEME_ADMIN, MenuConstant.USER_ADMIN,
                    MenuConstant.JOB_ADMIN, MenuConstant.INTERVIEW_ADMIN, MenuConstant.RESUME_CONFIG,
                    MenuConstant.DASHBOARD_ADMIN);
        } else if(roleName.contains(HR.key)) {
            return Arrays.asList(MenuConstant.DASHBOARD_ADMIN, MenuConstant.INTERVIEW_ADMIN);
        } else if(roleName.contains(USER.key)) {

        } else if(roleName.contains(STAFF.key)) {

        }
        return new ArrayList<>();
    }

}
